<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
    //5.定义一个数组，数组中包含了一些单词，统计包含'a'或'A'的单词有几个 (数组)
    document.write("在以下字符中:<br>");
    var arr = new Array("America", "Greece", "Britain", "Canada", "China", "Egypt");
    // var arr=["America","Greece","Britain","Canada","China","Egypt"];
    var count = 0;
    for (var i in arr) {   //使用for循环导入数组内容
        document.write(arr[i] + "<br>");
        if (arr[i].indexOf('a') != -1 || arr[i].indexOf('A') != -1) {
            count++;
        }
    }
    document.write("共有" + count + "个字符串中包含a或A.");

</script>
</body>
</html>